package com.method;

import sun.misc.Unsafe;

import javax.management.MBeanAttributeInfo;
import java.lang.reflect.Field;

/**
 * @author xiangui
 * 描述:
 * 时间: Create in 15:00 2018/7/11
 */
public class DirectMemoryOOM {

    private static final int _1M = 1024 * 1024;

    public static void main(String[] args) throws IllegalAccessException {

        Field field = Unsafe.class.getDeclaredFields()[0];
        field.setAccessible(true);
        Unsafe unsafe = (Unsafe) field.get(null);
        while (true){
            unsafe.allocateMemory(_1M);
        }

    }

}
